#define  _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<math.h>
int main()
{
	int N, bit, sum = 0;
	int a[10] = { 0 };
	scanf("%d", &N);
	for (int i = 0; i < 10; i++)
	{
		a[i] = pow(i, N);
	}
	for (int i = pow(10, N - 1); i < pow(10, N); i++)
	{
		int x = i;
		while (x)
		{
			bit = x % 10;
			sum = sum + a[bit];
			x = x / 10;
		}
		if (sum == i)
		{
			printf("%d\n", i);
		}
		sum = 0;
	}
	return 0;
}